package demo2;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: xiaotutu
 * Date: 2023-11-10
 * Time: 10:16
 */
//抽象类
abstract class Shape {

    public int age;

    public abstract void draw();//抽象方法
    private double acer;

    public Shape(double acer) {
        this.acer = acer;
    }
}


final class Cycle extends Shape {

    public Cycle(double acer) {
        super(acer);
    }

    @Override
    public void draw() {
        System.out.println("🟢");
    }
}

class Rect extends Shape {

    @Override
    public void draw() {
        System.out.println("️🖼️");
    }

    public Rect(double acer) {
        super(acer);
    }


}
public class Test2 {

    public static void drawMap(Shape shape) {
        shape.draw();
    }
    public static void main(String[] args) {
        drawMap(new Rect(11.3));
        drawMap(new Cycle(12.6));
    }
}

/*
// 抽象类：被abstract修饰的类
public abstract class Shape {
    // 抽象方法：被abstract修饰的方法，没有方法体
    abstract public void draw();
    abstract void calcArea();
    // 抽象类也是类，也可以增加普通方法和属性
    public double getArea(){
        return area;
    }
    protected double area; // 面积
}
*/

/*public interface 接口名称{
    // 抽象方法
    public abstract void method1(); // public abstract 是固定搭配，可以不写
    public void method2();
    abstract void method3();
    void method4();
// 注意：在接口中上述写法都是抽象方法，跟推荐方式4，代码更简洁
}*/
